Skip to content

Add --env to the CLI - #1567

Merged
ai merged 2 commits into
postcss:mainfrom
shreyanshj10:cli-env-option
Nov 17, 2026
Merged

ai merged 2 commits into
postcss:mainfrom
shreyanshj10:cli-env-option

Conversation

@shreyanshj10

Copy link
Copy Markdown
Contributor

autoprefixer --info always reads the default Browserslist section, so there was no way to inspect a specific environment short of setting BROWSERSLIST_ENV. This adds --env, passed straight through to the existing env option.

$ npx autoprefixer --info --env production

Both --env NAME and --env=NAME work, anywhere in the argument list. Browserslist's own CLI takes only the = form, but the space-separated one seemed worth accepting too — happy to drop it if you'd rather the two matched exactly. Missing or flag-shaped values exit 1 with a message rather than being silently ignored.

Added test/bin.test.js, which runs the binary against a temp Browserslist config with two sections. There was no test for bin/autoprefixer before, so it also covers --version and the help output.

Fixes #1338

Comment thread README.md Outdated
user-select: ms
```

If your Browserslist config has [environment sections], use `--env`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this docs, it is very rare use case to spend docs on it

Comment thread bin/autoprefixer Outdated
'Usage:\n' +
' autoprefixer --info\n'
' autoprefixer --info\n' +
' autoprefixer --info --env production\n'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same, remove, we don't need to promote this case

@shreyanshj10

Copy link
Copy Markdown
Contributor Author

Both removed — the README section is gone, and the --env line is out of the
Usage examples.

I left the one-line entry in the Options list so --help still mentions the flag
exists. Happy to drop that too if you'd rather it weren't listed at all.

@ai
ai merged commit 02d3343 into postcss:main Nov 17, 2026
9 checks passed
@ai

ai commented Nov 17, 2026

Copy link
Copy Markdown
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --env to CLI

2 participants